package com.hailong.zyt.utils;

/*
* 表单属性验证
*
*/


import com.hailong.zyt.beans.Student;
import org.springframework.ui.Model;
import org.thymeleaf.util.StringUtils;


public class FormChecker {

    public static boolean checkLogin(String id, String password, Model model) {
        boolean ok = true;
        if(StringUtils.isEmpty(id)) {
            model.addAttribute("em_id", "请填写学号");
            ok = false;
        }
        if(StringUtils.isEmpty(password)) {
            model.addAttribute("em_pwd", "请填写密码");
            ok = false;
        }
        return ok;
    }

    /*public static boolean checkRegister(Student student, String repwd, Model model){
        boolean ok = true;
        if(StringUtils.isEmpty(student.getStuId())) {
            model.addAttribute("em_id", "请填写学号");
            ok = false;
        }
        if(StringUtils.isEmpty(student.getPassword())) {
            model.addAttribute("em_pwd", "请填写密码");
            ok = false;
        }
        if(StringUtils.isEmpty(student.getEmail())) {
            model.addAttribute("em_em", "请填写邮箱");
            ok = false;
        }
        if(StringUtils.isEmpty(student.getName())) {
            model.addAttribute("em_na", "请填写姓名");
            ok = false;
        }
        if(StringUtils.isEmpty(student.getMajor())) {
            model.addAttribute("em_mj", "请填写专业");
            ok = false;
        }
        if(StringUtils.isEmpty(student.getSex())) {
            model.addAttribute("em_sx", "请填写性别");
            ok = false;
        }
        if(!student.getPassword().equals(repwd)){
            model.addAttribute("em_rp", "两次密码不一致");
            ok = false;
        }
        return ok;
    }*/

}
